12. Video: How Does K-Means Work?

How Does K-Means Work?

How Does K-Means Work?

Even before this video, you know most of what you needed to about how the k-means algorithm works:

  1. You choose k as the number of clusters you believe to be in your dataset or…
  2. You use the elbow method to determine k for your data.

Then this number of clusters is created within your dataset, where each point is assigned to each group.


However, to understand what edge cases might occur when grouping points together, it is necessary to understand exactly what the k-means algorithm is doing. Here is one method for computing k-means:

1. Randomly place k centroids amongst your data.

Then within a loop until convergence perform the following two steps:

2. Assign each point to the closest centroid.

3. Move the centroid to the center of the points assigned to it.

At the end of this process, you should have k-clusters of points.